package com.cn.yugan.Activity;

import android.media.MediaPlayer;
import android.os.Handler;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.WindowManager;
import android.widget.Toast;

import com.cn.yugan.mobile.R;
import com.cn.yugan.Widget.GifView.GifView;

/**
 * Created by Rover on 2016/8/15 .
 * Email 357319517@qq.com
 */
public class high extends AppCompatActivity {
    private GifView gif1, gif2, gif3, gif4, gif5;
    private GifView gif6, gif7, gif8, gif9;
    private GifView gif10, gif11, gif12, gif13;
    private GifView gif14, gif15, gif16, gif17;
    private MediaPlayer mp;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_high);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        init();

    }

    private void init() {
        ActionBar actinbar = getSupportActionBar();
        actinbar.hide();
        gif1 = (GifView) findViewById(R.id.giffun);
        gif1.setMovieResource(R.raw.dance);
        gif2 = (GifView) findViewById(R.id.gifzz1);
        gif2.setMovieResource(R.raw.tea);
        gif3 = (GifView) findViewById(R.id.gifzz2);
        gif3.setMovieResource(R.raw.tea);
        gif4 = (GifView) findViewById(R.id.gifzz3);
        gif4.setMovieResource(R.raw.tea);
        gif5 = (GifView) findViewById(R.id.gifzz4);
        gif5.setMovieResource(R.raw.tea);
        
        gif6 = (GifView) findViewById(R.id.gifzz5);
        gif6.setMovieResource(R.raw.cj);
        gif7 = (GifView) findViewById(R.id.gifzz6);
        gif7.setMovieResource(R.raw.cj);
        gif8 = (GifView) findViewById(R.id.gifzz7);
        gif8.setMovieResource(R.raw.cj);
        gif9 = (GifView) findViewById(R.id.gifzz8);
        gif9.setMovieResource(R.raw.cj);
        
        gif10 = (GifView) findViewById(R.id.gifzz9);
        gif10.setMovieResource(R.raw.cj);
        gif11 = (GifView) findViewById(R.id.gifzz10);
        gif11.setMovieResource(R.raw.cj);
        gif12 = (GifView) findViewById(R.id.gifzz11);
        gif12.setMovieResource(R.raw.cj);
        gif13 = (GifView) findViewById(R.id.gifzz12);
        gif13.setMovieResource(R.raw.cj);
        
        gif14 = (GifView) findViewById(R.id.gifzz13);
        gif14.setMovieResource(R.raw.tea);
        gif15 = (GifView) findViewById(R.id.gifzz14);
        gif15.setMovieResource(R.raw.tea);
        gif16 = (GifView) findViewById(R.id.gifzz15);
        gif16.setMovieResource(R.raw.tea);
        gif17 = (GifView) findViewById(R.id.gifzz16);
        gif17.setMovieResource(R.raw.tea);

        mp = MediaPlayer.create(this, R.raw.funnymusic);
        mp.start();

        mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mp) {
                Toast.makeText(high.this, "不要告诉其他人噢", Toast.LENGTH_LONG).show();
                gif1.setMovieResource(R.raw.shine);
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        high.this.finish();
                    }
                }, 4000);
            }
        });
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            mp.pause();
            high.this.finish();
        }
        return super.onKeyDown(keyCode, event);
    }
}
